<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="cn.school.mybaits.Dao.SubjectDao"%>
<%@page import="cn.school.mybaits.entity.Subject"%>
<%@page import="cn.school.mybaits.xml.MyBatisUtil"%>
<%@page import="org.apache.ibatis.session.SqlSession"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<%
		request.setCharacterEncoding("utf-8");
		String subjectName = request.getParameter("subjectname");
		String hour = request.getParameter("classhour");
		int classhour = Integer.parseInt(hour);
		String grade = request.getParameter("gradeid");
		int gradeid = Integer.parseInt(grade);
		
		SqlSession sess = MyBatisUtil.get();
		SubjectDao subjectDao = sess.getMapper(SubjectDao.class);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("subjectName", subjectName);
		map.put("classhour", classhour);
		map.put("gradeid", gradeid);
		int a = subjectDao.add(map);
		if (a > 0) {
			out.print("<h1>添加成功</h1>");
		} else {
			out.print("<h1>添加失败,重新<a href='Subject.jsp'>添加</a></h1>");
		}
		MyBatisUtil.close(sess);
	%>

</body>
</html>